<%@taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@page pageEncoding="UTF-8"%>
<%@include file="../WEB-INF/jspf/controlesessao.jspf"%>
<c:catch var ="catchException">
    <sql:update var="update" dataSource="jdbc/dbo_MicrosoftSQLServer">
        update Modulos set desc_modulo=?
        where id_modulo=?
        <sql:param value="${param.desc_modulo}"/>
        <sql:param value="${param.id_modulo}"/>
    </sql:update>

    <sql:update var="select" dataSource="jdbc/dbo_MicrosoftSQLServer">
       delete from grades where id_modulo=?
        <sql:param value="${param.id_modulo}"/>
    </sql:update>

        <c:forEach var='parameter' items='${paramValues}'>
            <c:if test="${fn:endsWith(parameter.key,'id_componente')}">
                <c:forEach var='value' items='${parameter.value}'>
                    <c:catch var ="catchException">
                        <sql:update var="insert" dataSource="jdbc/dbo_MicrosoftSQLServer">
                            insert into grades(id_curso,id_componente,id_modulo) values(?,?,?)
                            <sql:param value="${param.id_curso}"/>
                            <sql:param value="${value}"/>
                            <sql:param value="${param.id_modulo}"/>
                        </sql:update>
                    </c:catch>
                </c:forEach>
            </c:if>
        </c:forEach>

    <p>Registro Salvo com sucesso!</p>
</c:catch>
<c:if test = "${catchException!=null}">
    Erro : Não foi possível realizar a alteração.<br><br>
</c:if>
